<template>
  <div class="elec-report">
    <aside class="aside">
      <div class="search-wrap" @click="openDia">
        <img class="img" src="./images/search.png" alt="" />
        <span>搜索</span>
      </div>
      <el-tree
        node-key="id"
        indent="20"
        :data="data"
        :props="defaultProps"
        @node-click="handleNodeClick"
      />
    </aside>
    <main class="main">
      <header class="header">
        <div class="report" @click="changeSelMonth">
          <div class="day" :class="selMonth == 'day' ? 'select' : ''">日报</div>
          <div class="month" :class="selMonth == 'month' ? 'select' : ''">
            月报
          </div>
          <div class="year" :class="selMonth == 'year' ? 'select' : ''">
            年报
          </div>
        </div>
        <el-form :model="formData" size="large">
          <el-form-item label="查询日期:">
            <el-col :span="13">
              <el-date-picker
                v-model="value1"
                type="date"
                placeholder="请选择日期"
              />

              <el-button class="search">查询</el-button>
              <el-button class="export" :icon="Upload">导出</el-button>
            </el-col>
          </el-form-item>
        </el-form>
      </header>
      <div class="content">
        <h3>单位：kW.h</h3>
        <div class="table-wrap">
          <el-table
            max-height="480"
            :data="tableData"
            border
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="selection" />
            <el-table-column align="center" property="name" label="回路名称" />
            <el-table-column align="center" property="name" label="0时" />
            <el-table-column align="center" property="name" label="1时" />
            <el-table-column align="center" property="name" label="2时" />
            <el-table-column align="center" property="name" label="3时" />
            <el-table-column align="center" property="name" label="4时" />
            <el-table-column align="center" property="name" label="5时" />
            <el-table-column align="center" property="name" label="6时" />
            <el-table-column align="center" property="name" label="7时" />
            <el-table-column align="center" property="name" label="8时" />
            <el-table-column align="center" property="name" label="总计" />
          </el-table>
          <div style="padding-top: 15px">
            <Pagination
              @getDataList="getDataList"
              :pageSize="pageSize"
              :total="total"
              :currentPage="currentPage"
            />
          </div>
        </div>
      </div>
    </main>
    <SearchDia v-model:visible="dialogVisible" @serachDigSure="serachDigSure" />
  </div>
</template>
<script setup lang="ts">
import { Upload } from "@element-plus/icons-vue";
import SearchDia from "./component/DiaSearch";
import { ref, reactive } from "vue";
let search = ref("");
let pageSize = ref("10");
let total = ref(111);
let currentPage = ref(1);
let dialogVisible = ref(false);
let tableData = reactive([{ name: "sf" }, { name: "sf" }, { name: "sf" }]);

let selMonth = ref("day");
let value1 = ref("");
let formData = reactive({});
const defaultProps = {
  children: "children",
  label: "label",
};
const serachDigSure = () => {
  console.log("弹框确认");
};
const data = [
  {
    label: "Level one 1",
    children: [
      {
        label: "Level two 1-1",
        children: [
          {
            label: "Level three 1-1-1",
          },
        ],
      },
    ],
  },
  {
    label: "Level one 2",
    children: [
      {
        label: "Level two 2-1",
        children: [
          {
            label: "Level three 2-1-1",
          },
        ],
      },
      {
        label: "Level two 2-2",
        children: [
          {
            label: "Level three 2-2-1",
          },
        ],
      },
    ],
  },
  {
    label: "Level one 3",
    children: [
      {
        label: "Level two 3-1",
        children: [
          {
            label: "Level three 3-1-1",
          },
        ],
      },
      {
        label: "Level two 3-2",
        children: [
          {
            label: "Level three 3-2-1",
          },
        ],
      },
    ],
  },
];
const handleNodeClick = (data) => {
  console.log(data);
};
const changeSelMonth = (e) => {
  let list = [...e.target.classList].join(",");
  if (
    list.indexOf(selMonth.value) != "-1" ||
    (list != "day" && list != "month" && list != "year")
  )
    return;
  selMonth.value = e.target.className;
  e.target.classList.add("select");
};
const andleSelectionChange = () => {};
const openDia = () => {
  dialogVisible.value = true;
};
</script>
<style lang="scss" scoped>
.elec-report {
  padding: 14px 17px 19px 13px;
  display: flex;
  .aside {
    height: calc(100vh - 19px - 130px);
    width: 272px;
    margin-right: 10px;
    background-color: #fff;
    padding: 31px 0 24px 17px;
    .search-wrap {
      display: flex;
      align-items: center;
      background: #ffffff;
      border: 1px solid #176ff9;
      border-radius: 5px;
      height: 42px;
      width: 239px;
      padding-left: 28px;
      margin-bottom: 24px;
      cursor: pointer;

      span {
        font-weight: 400;
        color: #176ff9;
        font-size: 19px;
        padding-left: 11px;
      }
      .img {
        width: 19px;
        height: 19px;
      }
    }
  }
  .main {
    height: calc(100vh - 19px - 130px);
    width: calc(100vw - 295px - 161px);
    /* background-color: #fff; */
    .header {
      background: #ffffff;
      height: 145px;
      width: 100%;
      padding-top: 22px;
      padding-left: 30px;

      .el-form {
        padding-top: 19px;

        .el-button {
          font-size: 22px;
          font-weight: 400;
          color: #ffffff;
        }
        .search {
          width: 100px;
          height: 42px;
          border-radius: 5px;
          background: #0250f9;
          margin-left: 31px;
        }
        .export {
          width: 103px;
          height: 42px;
          border-radius: 5px;
          background: #fc4848;
          margin-left: 22px;
        }
        :deep(.el-button--large span) {
          margin: 4px !important;
        }
      }
      .report {
        display: flex;
        .select {
          background: #176ff9;
          border: none;
          color: #ffffff;
        }
        div {
          text-align: center;
          line-height: 40px;
          width: 113px;
          height: 40px;
          border-radius: 20px;
          font-weight: 500;
          font-size: 20px;
          color: #666666;
          border: 1px solid #cccccc;
          margin-left: 26px;
          cursor: pointer;
        }
        & div:first-child {
          margin-left: 0;
        }
      }
    }
    .content {
      background: #ffffff;
      margin-top: 14px;
      width: 100%;
      height: calc(100vh - 19px - 173px - 116px);
      padding-top: 22px;
      h3 {
        font-size: 20px;
        font-weight: 500;
        color: #333333;
        margin-left: 37px;
      }
      .table-wrap {
        padding: 22px 24px 0 30px;
        :deep(.el-table__body td.el-table__cell) {
          height: 4.67vh;
        }
      }
    }
  }
}
</style>
